cmake_minimum_required(VERSION 3.20)
project(TEST)

if(CMAKE_CONFIGURATION_TYPES)
    list(APPEND CMAKE_CONFIGURATION_TYPES MyDebug MyRelease)
    list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
    set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Add the configurations that we need" FORCE)
endif()

set(CMAKE_CXX_FLAGS_MYDEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mydebugflag" CACHE STRING "Flags used by the C++ compiler during MyDebug builds." FORCE)
set(CMAKE_C_FLAGS_MYDEBUG "${CMAKE_C_FLAGS_DEBUG} -mydebugflag" CACHE STRING "Flags used by the C compiler during MyDebug builds." FORCE)

set(CMAKE_EXE_LINKER_FLAGS_MYDEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -mydebug_exe_linkflag" CACHE STRING "Flags used by the C compiler during MyDebug builds." FORCE)
set(CMAKE_MODULE_LINKER_FLAGS_MYDEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} -mydebug_module_linkflag" CACHE STRING "Flags used by the C compiler during MyDebug builds." FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_MYDEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -mydebug_shared_linkflag" CACHE STRING "Flags used by the C compiler during MyDebug builds." FORCE)
set(CMAKE_STATIC_LINKER_FLAGS_MYDEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -mydebug_static_linkflag" CACHE STRING "Flags used by the C compiler during MyDebug builds." FORCE)

set(CMAKE_CXX_FLAGS_MYRELEASE "${CMAKE_CXX_FLAGS_RELEASE} -myreleaseflag" CACHE STRING "Flags used by the C++ compiler during MyRelease builds." FORCE)
set(CMAKE_C_FLAGS_MYRELEASE "${CMAKE_C_FLAGS_RELEASE} -myreleaseflag" CACHE STRING "Flags used by the C compiler during MyRelease builds." FORCE)

set(CMAKE_EXE_LINKER_FLAGS_MYRELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -myrelease_exe_linkflag" CACHE STRING "Flags used by the C compiler during MyRelease builds." FORCE)
set(CMAKE_MODULE_LINKER_FLAGS_MYRELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -myrelease_module_linkflag" CACHE STRING "Flags used by the C compiler during MyRelease builds." FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_MYRELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -myrelease_shared_linkflag" CACHE STRING "Flags used by the C compiler during MyRelease builds." FORCE)
set(CMAKE_STATIC_LINKER_FLAGS_MYRELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -myrelease_static_linkflag" CACHE STRING "Flags used by the C compiler during MyRelease builds." FORCE)


set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug,MyDebug>:Debug>DLL")

add_library(lib1 lib1.h lib1.cpp)
add_library(lib2 SHARED lib2.h lib2.cpp)
add_library(lib3 MODULE lib3.h lib3.cpp)

add_executable(main lib1.h lib2.h main.cpp)
target_link_libraries(main lib1 lib2)
add_dependencies(main lib3)
